﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//using System.Data.Linq;

public partial class morning_gdzgTop : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.stime.Value = DateTime.Now.ToString("yyyy-MM-dd");
            var typeTop = Server.UrlDecode(Request["typeTop"]);
            ddlType.Text = typeTop;
            bd();
        }
    }
    //public int GetPage()
    //{
    //    return AspNetPager1.CurrentPageIndex;
    //}


    void bd()
    {
   
        TemporaryModel.TemporaryEntities dal = DAL.DBManager.GetTempEmtity();
        var stockTop = dal.StockBusinessTop.AsQueryable();

        var typeTop = Server.UrlDecode(Request["typeTop"]);
        var date = Server.UrlDecode(Request["date"]);
        var userName = Server.UrlDecode(Request["userName"]);

        if (userName != null)
            stockTop = stockTop.Where(x => x.userName == userName);
        if (date != null)
        {
            DateTime dt = DateTime.Parse(date);
            stockTop = stockTop.Where(x => x.wtDate == dt);
        }
           
        int i = 1;
              //var sTop = from a in stockTop
        //           orderby a.dayrate
        //           select new { rowNum =, a.id, a.userName, a.ydayTop, a.dayrate, a.totalrate, a.amount, a.stockPositions, a.dProfitRate, a.totalAmount };
        if (typeTop == "总收益排名")
        {
            var sss = from a in stockTop
                      orderby a.totalrate descending
                      select new { a.id, a.userName, a.ydayTop, a.dayrate, a.totalrate, a.amount, a.stockPositions, a.dProfitRate, a.totalAmount };
            var st = sss.AsEnumerable().Select((a) => new { rowNum = i++, a.id, a.userName, a.ydayTop, a.dayrate, a.totalrate, a.amount, a.stockPositions, a.dProfitRate, a.totalAmount }).AsQueryable();

            Repeater1.DataSource = st;
            Repeater1.DataBind();
        }
        else
        {
           var  sss = from a in stockTop
                      orderby a.dayrate descending
                      select new { a.id, a.userName, a.ydayTop, a.dayrate, a.totalrate, a.amount, a.stockPositions, a.dProfitRate, a.totalAmount };
           var st = sss.AsEnumerable().Select((a) => new { rowNum = i++, a.id, a.userName, a.ydayTop, a.dayrate, a.totalrate, a.amount, a.stockPositions, a.dProfitRate, a.totalAmount }).AsQueryable();

           Repeater1.DataSource = st;
           Repeater1.DataBind();
        }
    
        
    }
}